import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zyj
 * @date 2022年06月10日 14:46
 */
public class newFixedThreadPoolDemo {
    public static void main(String[] args) {
        ExecutorService  service  = Executors.newFixedThreadPool(5);

        for (int i = 0; i < 5; i++) {
            final int index = i;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            service.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("第" + index + "个线程" + Thread.currentThread().getName());
                }
            });



        }
        service.shutdown();

    }
}
